package com.meelive.ingkee.iknetwork.diagnose.model

import android.graphics.Color
import android.util.TypedValue
import com.gmlive.common.ui.util.DisplayHelper
import com.meelive.ingkee.iknetwork.diagnose.DiagnoseProvider
import com.meelive.ingkee.iknetwork.diagnose.R

/**
 * @param textSize Int: 单位  Float: 值
 * @param textColor Int: 按压颜色 Int: 默认颜色
 */
class CopyViewConfig private constructor(val pressBg: BackGroundConfig?,
                                     val unPressBg: BackGroundConfig?,
                                     val strokeColor: Int,
                                     val strokeWidth: Int,
                                     val textColor: Pair<Int, Int>,
                                     val textSize: Pair<Int, Float>) {

    class Builder {

        private var pressBg: BackGroundConfig? = null

        private var unPressBg: BackGroundConfig? = null

        private var strokeColor: Int = 0

        private var textPressColor: Int = 0

        private var textUnPressColor: Int = 0

        private var strokeWidth: Int = DisplayHelper.dpToPx(1)

        private var textSizeUnit: Int = TypedValue.COMPLEX_UNIT_DIP

        private var textSize: Float = 18f

        init {
            DiagnoseProvider.getAppContext().apply {
                pressBg = BackGroundConfig(resources.getColor(R.color.networkdiagnose_inke_color_1))
                unPressBg = BackGroundConfig(resources.getColor(R.color.networkdiagnose_inke_color_29))
                strokeColor = resources.getColor(R.color.networkdiagnose_inke_color_33)
                textPressColor = resources.getColor(R.color.networkdiagnose_inke_color_12)
                textUnPressColor = resources.getColor(R.color.networkdiagnose_inke_color_33)
            }
        }

        fun setPressBackgroundConfig(config: BackGroundConfig): Builder {
            pressBg = config
            return this
        }

        fun setUnPressBackgroundConfig(config: BackGroundConfig): Builder {
            unPressBg = config
            return this
        }

        fun setBackgroundStrokeColor(color: Int): Builder {
            strokeColor = color
            return this
        }

        fun setBackgroundStrokeWidth(size: Int): Builder {
            strokeWidth = size
            return this
        }

        fun setTextPressColor(press: Int): Builder {
            textPressColor = press
            return this
        }

        fun setTextUnPressColor(unPress: Int): Builder {
            textUnPressColor = unPress
            return this
        }

        fun setTextSize(unit: Int, size: Float): Builder {
            textSizeUnit = unit
            textSize = size
            return this
        }

        fun build(): CopyViewConfig {
            return CopyViewConfig(pressBg, unPressBg, strokeColor, strokeWidth, Pair(textPressColor, textUnPressColor), Pair(textSizeUnit, textSize))
        }
    }
}

data class BackGroundConfig @JvmOverloads constructor(val color: Int, val radius: Float = DisplayHelper.dpToPx(45).toFloat())

data class TitleViewConfig @JvmOverloads constructor(val backViewColor: Int = Color.TRANSPARENT, val titleColor: Int = Color.parseColor("#333333"))